﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CommonTools.Class;

namespace CommonTools.FreeProxy
{
    public class xici : IProxy
    {
        string url = "http://api.xicidaili.com/free2016.txt";
        public IList<Proxy> GetProxy()
        {
            var pstr = HttpHelper.HttpGet(url, "", "text/html");
            var q=pstr.Split(new string[] { "\r", "\n" },StringSplitOptions.RemoveEmptyEntries);
            var proxy = new List<Proxy>();
            foreach(var i in q)
            {
                var s=i.Split(':');
                proxy.Add(new Proxy
                {
                    IP=s[0],
                    Port=int.Parse(s[1])
                });
            }
            return proxy;
        }
    }
}
